package com.example.fbneo_crc2;

import com.google.gson.Gson;

import java.io.File;
import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;

import javax.net.ssl.HttpsURLConnection;

public class GetHttpData {

    public static void main(String[] str) {






//        try {
//            System.out.println("--------------------------------------------------");
//
//            //脚本列表
//            for (int i = 450; i < 99999999; i++) {
//                Thread.sleep(10);
//                String timeStamp = String.valueOf(System.currentTimeMillis());
//                String ngid = "" + i;
//                String randomNum = "kSMXIOgyEHvk41JHuLaSA194d42e7788";
//                String sign = MD5.MD5(String.format("ngid=%s&pageNum=1&pageSize=100&randomNum=%s&timeStamp=%s&type=2AndroidJW%%fk_K[l|s3p=qDxT|n9qr?jw*2)8Tvr06fR3+0Xj&uytI})S[F^A^AvhW62Tvo5*Rz]zo", ngid, randomNum, timeStamp)).toLowerCase();
//                String post = String.format("timeStamp=%s&ngid=%s&sign=%s&pageSize=100&type=2&pageNum=1&randomNum=%s", timeStamp, ngid, sign, randomNum);
//                String json = HttpUtil.sendPost("https://japi.x7sy.com/v1/game-on-hook/schemes",
//                        "user-agent: SMSDK/8.8.1/Android/13/phone/OnePlus_IN2010/0c604e084ef3d1c9b7b7eb9c89c539ad/6d5eabde460377e0736e54ae165c430a\n" +
//                                "x7sy-dev: oaid=A2F380B89604499895E43C60D40A8D127a74f795776191ba497c5df4ef936b90&imei=-1&new_uuid=6d5eabde460377e0736e54ae165c430a&uuid=0c604e084ef3d1c9b7b7eb9c89c539ad&is_simulator=-1&idfa=6d5eabde460377e0736e54ae165c430a&temp_idfa=-1&tgid=15468&sign=e4dede3233bef5078ba4c78591a38d56&ua=Mozilla/5.0 (Linux; Android 13; IN2010 Build/RKQ1.211119.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36&packtask_id=166822&customization_system_type=HydrogenOS&customization_system_version=&heightPixels=2293&widthPixels=1080&network=wifi&packageName=com.zysgjhldyxq.x7sy&sdkLoginType=1&hostPackageName=com.zysgjhldyxq.x7sy&isDiscountPromotion=-1&subcontractParam=-1&firstStartTime=0\n" +
//                                "i18n: 1/1/-1/GMT+08:00/-1/-1/5/5/-1\n" +
//                                "jwt-encoding: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtaWQiOiIxNjYzODIxOCIsInVzZXJfYXV0aF9zdHJpbmciOiI1NmRiMzkyNDFjY2M1NzEwZDBkODQ2YjNkOWVhYjhjNCIsInV1aWQiOiIwYzYwNGUwODRlZjNkMWM5YjdiN2ViOWM4OWM1MzlhZCIsImluc3RhbGxfaWQiOjUwMTMxNjUwLCJhZGRfdGltZSI6MTczODczODA5MSwibmV3X3V1aWQiOiI2ZDVlYWJkZTQ2MDM3N2UwNzM2ZTU0YWUxNjVjNDMwYSJ9.KtvrkDrYX3_-DoWHeNAYyqSzhIPEqVR9hmJVBFMLpRw\n" +
//                                "x7devicetoken: \n" +
//                                "x7-version-code: 2\n" +
//                                "content-type: application/x-www-form-urlencoded\n" +
//                                "content-length: 144\n" +
//                                "accept-encoding: gzip",
//                        post,
//                        "utf-8");
//                if (json == null) {
//                    System.out.println(i+" 接口出错！");
//                    continue;
//                }
//                if (json.contains("{\"gameOnHookSchemes\":[],\"gameScriptLabels\":[],\"hasNext\":0}")) {
//                    System.out.println(i+" 无数据");
//                    continue;
//                }
//                System.out.println(json);
//                FileUtil.SaveFileAs(json, "D://jb/" + i);
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }


//        try {
//            System.out.println("--------------------------------------------------");
//            File file = new File("D:\\jb");
//
//
////            file.isDirectory()
//            //脚本列表
//            for (File files : file.listFiles()) {
//
//
//                JbBase jbList = new Gson().fromJson(FileUtil.getFileContent(files.getAbsolutePath()), JbBase.class);
//
//
//                for (JbBase.GameOnHookSchemesBean jb : jbList.getGameOnHookSchemes()) {
//                    Thread.sleep(10);
//                    String timeStamp = String.valueOf(System.currentTimeMillis());
//                    String id = jb.getId()+"";
//                    String randomNum = "KemsyOgVHkiR0sXb31qEF194d5935f67";
////
//
//                    String sign = MD5.MD5(String.format("id=%s&randomNum=%s&timeStamp=%s&type=2AndroidJW%%fk_K[l|s3p=qDxT|n9qr?jw*2)8Tvr06fR3+0Xj&uytI})S[F^A^AvhW62Tvo5*Rz]zo", id, randomNum, timeStamp)).toLowerCase();
////
//                    String post = String.format("timeStamp=%s&sign=%s&id=%s&type=2&randomNum=%s", timeStamp, sign, id, randomNum);
//                    String json = HttpUtil.sendPost("https://japi.x7sy.com/v1/game-on-hook/start",
//                            "user-agent: SMSDK/8.8.1/Android/13/phone/OnePlus_IN2010/0c604e084ef3d1c9b7b7eb9c89c539ad/6d5eabde460377e0736e54ae165c430a\n" +
//                                    "x7sy-dev: oaid=A2F380B89604499895E43C60D40A8D127a74f795776191ba497c5df4ef936b90&imei=-1&new_uuid=6d5eabde460377e0736e54ae165c430a&uuid=0c604e084ef3d1c9b7b7eb9c89c539ad&is_simulator=-1&idfa=6d5eabde460377e0736e54ae165c430a&temp_idfa=-1&tgid=15468&sign=e4dede3233bef5078ba4c78591a38d56&ua=Mozilla/5.0 (Linux; Android 13; IN2010 Build/RKQ1.211119.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36&packtask_id=166822&customization_system_type=HydrogenOS&customization_system_version=&heightPixels=2293&widthPixels=1080&network=wifi&packageName=com.zysgjhldyxq.x7sy&sdkLoginType=1&hostPackageName=com.zysgjhldyxq.x7sy&isDiscountPromotion=-1&subcontractParam=-1&firstStartTime=0\n" +
//                                    "i18n: 1/1/-1/GMT+08:00/-1/-1/5/5/-1\n" +
//                                    "jwt-encoding: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtaWQiOiIxNjYzODIxOCIsInVzZXJfYXV0aF9zdHJpbmciOiI1NmRiMzkyNDFjY2M1NzEwZDBkODQ2YjNkOWVhYjhjNCIsInV1aWQiOiIwYzYwNGUwODRlZjNkMWM5YjdiN2ViOWM4OWM1MzlhZCIsImluc3RhbGxfaWQiOjUwMTMxNjUwLCJhZGRfdGltZSI6MTczODcxOTQ3MiwibmV3X3V1aWQiOiI2ZDVlYWJkZTQ2MDM3N2UwNzM2ZTU0YWUxNjVjNDMwYSJ9.RIU2GOd-Lvl4vB2qkqzQ2XeGmkzSzKSTIgfOD15pp58\n" +
//                                    "x7devicetoken: \n" +
//                                    "x7-version-code: 2\n" +
//                                    "content-type: application/x-www-form-urlencoded",
//                            post,
//                            "utf-8");
//                    if (json == null) {
//                        System.out.println(id + " 接口出错！");
//                        continue;
//                    }
//                    if (json.contains("{\"gameOnHookSchemes\":[],\"gameScriptLabels\":[],\"hasNext\":0}")) {
//                        System.out.println(id + " 无数据");
//
//                        continue;
//                    }
//                    System.out.println(json);
//
//                    new File("D://jb2/",files.getName()).mkdirs();
//                    FileUtil.SaveFileAs(json, "D://jb2/" + files.getName() +"/"+id);
//
//                }
//
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }




//        File fileList = new File("C:\\Users\\Administrator\\Desktop\\小7挂机助手\\json2");
//        for (File file : fileList.listFiles()) {
//            if(file.isDirectory()){
////                file.renameTo(new File(file.getAbsolutePath() .replace(".json","")));
//            }else{
//
////                file.renameTo(new File(file.getAbsolutePath().substring(0,file.getAbsolutePath().length()-2)));
//                try{
//
//                    JbGameBase xyBaseGame = new Gson().fromJson(FileUtil.getFileContent(file.getAbsolutePath()), JbGameBase.class);
//                    file.renameTo(new File(file.getParentFile(),xyBaseGame.getNgid()+".game"));
//                }catch (Exception e){
//                    e.printStackTrace();
//                }
//            }
//        }


        File fileList = new File("C:\\Users\\Administrator\\Desktop\\小7挂机助手\\all");
//        for (File file : fileList.listFiles(new FilenameFilter() {
//            @Override
//            public boolean accept(File dir, String name) {
//                if(name.endsWith("game")){
//                    return true;
//                }
//                return false;
//            }
//        })) {
//            if(file.isDirectory()){
//            }else{
//                try{
//                    JbGameBase xyBaseGame = new Gson().fromJson(FileUtil.getFileContent(file.getAbsolutePath()), JbGameBase.class);
//                    if(new File(fileList,xyBaseGame.getNgid()+".json").isFile()){
//                        JbListBase jbList = new Gson().fromJson(FileUtil.getFileContent(new File(fileList,xyBaseGame.getNgid()+".json").getAbsolutePath()), JbListBase.class);
//
//                        JbListNewBase listNew=new JbListNewBase(xyBaseGame.getNgid(),xyBaseGame.getGameName(),jbList);
//                        FileUtil.SaveFileAs(new Gson().toJson(listNew),new File(fileList,xyBaseGame.getNgid()+".jsonNew").getAbsolutePath());
//
//
//                    }else{
//
////                        System.out.println("noJb "+xyBaseGame.getNgid()+" "+xyBaseGame.getGameName());
//                    }
////                    file.renameTo(new File(file.getParentFile(),xyBaseGame.getNgid()+".game"));
//                }catch (Exception e){
//                    e.printStackTrace();
//                }
//            }
//        }

//        for (File file : fileList.listFiles(new FilenameFilter() {
//            @Override
//            public boolean accept(File dir, String name) {
//                if(name.endsWith(".jsonNew")){
//                    return true;
//                }
//                return false;
//            }
//        })) {
//            if(file.isDirectory()){
//            }else{
//                try{
//                    JbListNewBase listNew=new Gson().fromJson(FileUtil.getFileContent(file.getAbsolutePath()), JbListNewBase.class);
//                    File jbFile=new File(file.getParentFile(),listNew.getId());
//                    new File(file.getParentFile(),"jb").mkdirs();
//                    FileUtil.copyDir(jbFile.getAbsolutePath(),new File(file.getParentFile(),"jb/"+listNew.getId()).getAbsolutePath());
//
//
//                }catch (Exception e){
//                    e.printStackTrace();
//                }
//            }
//        }




//        File file = new File("C:\\Users\\Administrator\\Desktop\\小7隐私协议\\json2\\json(3)\\json");
//        orderByDate3(file.getAbsolutePath());

    }


}
